window.onload=function(){
		var spanCode=document.getElementById("yzm");
		spanCode.innerHTML = Rnd();
		//随机验证码
		function Rnd(){
		var str = "abcdefghijklmnopqrstuvwxyz0123456789";
		var arr = str.split("");
		var l = arr.length;
		var i1 = Math.floor(Math.random()*l);
		var i2 = Math.floor(Math.random()*l);
		var i3 = Math.floor(Math.random()*l);
		var i4 = Math.floor(Math.random()*l);
		return arr[i1]+arr[i2]+arr[i3]+arr[i4];
		console.log(arr);
	};
	var taggle=document.getElementById("qiehuan");
		taggle.onclick=function(){
			spanCode.innerHTML = Rnd();
		}
	
//输入框提示
	var ipt=document.getElementsByTagName("input");
	//手机号提示
	var sp=document.getElementById("ts1");
	var sp2=document.getElementById("ts2");
	var sp3=document.getElementById("ts3");
	//密码号提示
	var sp4=document.getElementById("ts4");
	var sp5=document.getElementById("ts5");
	var sp6=document.getElementById("ts6");
	
	//密码确认

	//console.log(ipt[0]);
	var arr=[false,false,false,false,false];
	ipt[0].onfocus=function(){
		//sp.innerHTML="请输入您的电话号";
		if(ipt[0].value==""){
			sp.style.display="block";
			sp2.style.display="none";
			sp3.style.display="none";
		}
	}
	ipt[0].onblur=function(){
		
		sp.style.display="none";
		//验证是否正确
		var re = /^[1-3]\d{10}$/ ;
		if (re.test(ipt[0].value)){  
			sp3.style.display="block";
			sp2.style.display="none";
			arr[0]="true";
			
		} else {
			sp2.style.display="block";
		}
	//console.log(sp.innerHTML);
	}
	//密码验证
	ipt[1].onfocus=function(){
		//sp.innerHTML="请输入您的电话号";
		if(ipt[0].value==""){
			sp4.style.display="block";
			sp3.style.display="none";
		}
	}
	
	ipt[1].onblur=function(){
		var Em=document.getElementsByTagName("em");
		sp3.style.display="none";
		//验证是否正确
		var ruo = /^\d{6,20}$/ ;
		var zhong = /^[a-z0-9]{6,20}$/ ;
		var qiang = /^[a-z0-9A-Z]{6,20}$/ ;
		if (ruo.test(ipt[1].value)){  
			sp6.style.display="block";
			Em[0].style.background="orange";
			arr[2]="true";
		} else {
			sp5.innerHTML="请输入正确的手机号";
		}
		if (zhong.test(ipt[1].value)){  
			sp6.style.display="block";
			Em[0].style.background="orange";
			Em[1].style.background="orange";
			arr[2]="true";
		} else {
			sp5.innerHTML="请输入正确的手机号";
		}
		if (qiang.test(ipt[1].value)){  
			sp6.style.display="block";
			Em[0].style.background="orange";
			Em[1].style.background="orange";
			Em[2].style.background="orange";
			arr[2]="true";
		} else {
			sp5.innerHTML="请输入正确的手机号";
		}
	//console.log(sp.innerHTML);
		
	}
	ipt[2].onblur=function(){
			if(ipt[1].value==ipt[2].value){
				
				ts8.style.display="none";
				ts7.style.display="none";
				ts9.style.display="block";
				sp4.style.display="none";
				arr[2]="true";
			}else{
				ts7.style.display="none";
				ts9.style.display="none";
				ts8.style.display="block";
			}
			
		}
		ipt[2].onfocus=function(){
			ts9.style.display="none";
			ts8.style.display="none";
			ts7.style.display="block";
			}
		
		
		
		ipt[3].onblur=function(){
			var yanz=document.getElementById("yz");
			//console.log(yanz);
			var tup1=document.getElementById("yzm");
			console.log(tup1.innerHTML);
			
			if(yanz.value == tup1.innerHTML){
				
			ts11.style.display="block";
			ts10.style.display="none";	
			arr[3]="true";
			}else{
			ts10.style.display="block";	
			ts11.style.display="none";
			}
		}	
		
		var inp=document.getElementById("aa");
		//console.log(inp);
		if(inp.checked){
			arr[4]="true";
		}else{};
		
		
		
		//console.log(arr[0]);
		var Btn=document.getElementById("btn");
			Btn.onclick=function(){	
				for(var i=0;i<4;i++){
				arr.index=i;
				if(arr="true"){
				
				
				var username = document.getElementById("username").value;
        		var pwd = document.getElementById("pwd").value;
					
				setCookie("username", username, 30);
                setCookie("password", pwd, 30);
                alert("注册成功！！!")
					 window.location.href = "../html/denglu.html";
				}else{
					window.location="";
				}	
			}	
		}
		
}